package com.itita.ww2.handler.requesthandler.chat;

import java.sql.SQLException;

import com.itita.ww2.core.ServerService;
import com.itita.ww2.core.WW2Exception;
import com.itita.ww2.game.user.UserService;
import com.itita.ww2.model.user.UserProfile;
import com.itita.ww2.utils.handler.IRequestOper;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.entities.data.SFSObject;

/**
 * 世界聊天
 * @author NorthLan
 *
 */
public class WorldChat implements IRequestOper {

	@Override
	public boolean execute(String requestCMD, User user, ISFSObject params) throws WW2Exception, SQLException {
		UserProfile userProfile = UserService.getInstance().getUserProfile(user);

		ISFSObject backObj = new SFSObject();
		backObj.putUtfString("msg", params.getUtfString("msg"));
		backObj.putInt("sid", userProfile.getUid());
		backObj.putUtfString("sname", userProfile.getNickname());

		ServerService.getInstance().getMainExtension().send(requestCMD, backObj,
				ServerService.getInstance().getMainExtension().getParentZone().getUserManager().getAllUsers());
		return true;
	}

}
